package com.ml.mall.utils;

import com.ml.mall.consts.HttpConsts;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @description:
 * @author kyyang
 * @date 2021/7/12 22:40
 * @version 1.0
 */
public class RedissonUtils {


    private static Object multiObj = new Object();
    private static RedissonClient redisson;
    protected static Config config;

    private static final String COMMA = ",";

    static {
        config = new Config();
        config.setNettyThreads(128);
        config.useSingleServer()
                .setRetryAttempts(5)
                .setRetryInterval(1000)
                .setConnectTimeout(20000)
                .setTimeout(30000) // 这里要配置大些默认只有3000
                .setPingTimeout(5000)
                .setIdleConnectionTimeout(60000)
                .setAddress(HttpConsts.REDISSION_REDIS_HOST)
        ;
    }

    public static Config getConfig() {
        return config;
    }

    public static RedissonClient getRedisson() {
        synchronized (multiObj) {
            if (redisson == null) {
                redisson = Redisson.create(config);
            }
        }
        return redisson;
    }


}
